package com.jsmtr.rms.controller;


import java.text.SimpleDateFormat;
import java.util.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.jsmtr.rms.entity.*;
import com.jsmtr.rms.utils.ResultBean;
import com.jsmtr.rms.utils.StringTools;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import org.apache.axis2.util.SessionUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import com.jsmtr.rms.entity.vo.ProjectForm;
import com.jsmtr.rms.service.IDoZZService;
import com.jsmtr.rms.service.IProjectService;
import com.jsmtr.rms.service.IUtilService;
import com.jsmtr.rms.utils.DateTools;
import com.jsmtr.rms.utils.EnumTools;

@Controller
@RequestMapping("/Project")
public class ProjectController {

    @Resource
    private IProjectService projectService;

    @Resource
    private IUtilService utilService;

    @Resource
    private IDoZZService doZZService;


    //[start] 查询招聘方案

    /*招聘方案*/
    @RequestMapping("/")
    public String Index() {

        //20180816返回页面前更新招聘方案状态
        updateProjectState();
        return "/Project/index";
    }



    //region 读取通用流程json
    @ResponseBody
    @RequestMapping(value = "/getNomalFlows")
    public  ResultBean getNomalFlows(){
        ResultBean resultBean=new ResultBean();
        EnumTools.FlowNomalState[] nomalStates=  EnumTools.FlowNomalState.values();
        if (nomalStates.length>0){
            List<ProjectInfoFlow> projectInfoFlowList=new ArrayList<>();
            for (EnumTools.FlowNomalState nomalState : nomalStates) {
                if (!nomalState.name().equalsIgnoreCase("简历筛选")&&!nomalState.name().equalsIgnoreCase("录用")
                        &&!nomalState.name().equalsIgnoreCase("毕业生推荐")){
                    ProjectInfoFlow infoFlow=new ProjectInfoFlow();
                    infoFlow.setFid(nomalState.ordinal());
                    infoFlow.setFname(nomalState.name());
                    infoFlow.setNickname(nomalState.name());
                    if(nomalState.name().equalsIgnoreCase("面试")){
                        infoFlow.setDisplay("否");
                    }else{
                        infoFlow.setDisplay("是");
                    }
                    infoFlow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    projectInfoFlowList.add(infoFlow);
                }
            }
            resultBean.setState(true);
            resultBean.setMessage("读取流程成功!");
            resultBean.setDatas(projectInfoFlowList);
        }else{
            resultBean.setState(false);
            resultBean.setMessage("读取流程失败!");
        }

        return  resultBean;
    }
    //endregion

    /**
     * 获取招聘方案数据信息
     * @param request
     * @param response
     * @param project
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getProListLayuiJson", method = RequestMethod.GET)
    public LayuiDataTableResultBean getProLayuiJson(HttpServletRequest request, HttpServletResponse response, ProjectInfo project) {
        try {
            int page = Integer.parseInt(request.getParameter("page"));
            int limit = Integer.parseInt(request.getParameter("limit"));

            int pstateInt = -1;
            try {
                pstateInt = Integer.parseInt(request.getParameter("key[pstate]"));
            } catch (NumberFormatException ignored) {

            }
            String pnameTemp = request.getParameter("key[pname]");
            if (pnameTemp == null) {
                pnameTemp = "";
            }

            Map<String, Object> map = projectService.getProjectSql(page, limit,project, pstateInt, pnameTemp);
            double pageCount = (Double) map.get("pageCount");
            double allcount = (Double) map.get("count");
            JSONArray jsonArray = new JSONArray();
            int num = 1;
            if (pageCount != 0) {
                Object object = map.get("list");
                for (ProjectInfo _project : (List<ProjectInfo>) object){
                    JSONObject jsonObject = JSONObject.fromObject(project);
                    jsonObject.put("id_cb","cb_" + _project.getId());
                    jsonObject.put("id",limit * (page - 1) + num);
                    jsonObject.put("recruittype",EnumTools.RecruitType.values()[_project.getRecruittype()]);
                    jsonObject.put("startdate",(_project.getStartdate() == null ? "" : DateTools.toLenStr(_project.getStartdate())));
                    jsonObject.put("enddate",(_project.getEnddate() == null ? "" : DateTools.toLenStr(_project.getEnddate())));
                    jsonObject.put("adddate",DateTools.toLenStr(_project.getAdddate()));
                    jsonObject.put("state",EnumTools.ProjectState.values()[_project.getState()]);
                    jsonObject.put("pdisplay","是");
                    jsonObject.put("pname",_project.getPname());
                    jsonObject.put("adduname",_project.getAdduname());
                    jsonArray.add(jsonObject);
                    num++;
                }
            }

            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCode(0);
            result.setMsg("success");
            result.setCount((int) allcount);
            result.setData(jsonArray);

            return result;
        } catch (Exception e) {
            e.printStackTrace();

            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCount(-1);
            result.setMsg("err");
            return result;
        }
    }

   /* @SuppressWarnings("unchecked")
    @RequestMapping("/getprojects")
    public void getprojects(HttpServletRequest request, HttpServletResponse response, ProjectInfo project) {
        try {
            int perpage = Integer.parseInt(request.getParameter("perpage"));
            int page = Integer.parseInt(request.getParameter("page"));

            Map<String, Object> map = projectService.getProjects(page, perpage, project);
            StringBuilder result = new StringBuilder();
            double pageCount = (Double) map.get("pageCount");
            double allcount = (Double) map.get("count");

            if (pageCount != 0) {
                Object object = map.get("list");
                int num = 1;
                for (ProjectInfo _project : (List<ProjectInfo>) object) {
                    result.append("<tr><td><input type=\"checkbox\" id='cb_" + _project.getId() + "' /></td>");
                    result.append("<td>" + (perpage * (page - 1) + num) + "</td>");
                    result.append("<td>" + _project.getPname() + "</td>");
                    result.append("<td>" + EnumTools.RecruitType.values()[_project.getRecruittype()] + "</td>");
                    result.append("<td>是</td>");
                    result.append("<td>" + (_project.getStartdate() == null ? "" : DateTools.toLenStr(_project.getStartdate())) + "</td>");
                    result.append("<td>" + (_project.getEnddate() == null ? "" : DateTools.toLenStr(_project.getEnddate())) + "</td>");
                    result.append("<td>" + _project.getAdduname() + "</td>");
                    result.append("<td>" + DateTools.toLenStr(_project.getAdddate()) + "</td>");
                    result.append("<td>" + EnumTools.ProjectState.values()[_project.getState()] + "</td></tr>");
                    num++;
                }
            } else {
                result.append("<tr style='display:none'><td></td></tr>");
            }
            result.append("<input type='hidden' id='pageCount' value='" + pageCount + "' />");
            result.append("<input type='hidden' id='allCount' value='" + allcount + "' />");
            utilService.printTextResult(result.toString(), response);
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printTextResult("<tr><td colspan='9'>读取数据失败</td></tr><input type='hidden' id='pageCount' value='0' /><input type='hidden' id='allCount' value='0' />", response);
        }
    }*/

    //[end]

    //region 根据发布的结束时间更新招聘方案状态为招聘结束
    private void updateProjectState(){
        try{
            BaseConfig autoClose=utilService.findConfig("autocloseproject");
            if(autoClose.getCont().equalsIgnoreCase("是")){
                projectService.endProjectByEndTime();
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }
    //endregion

    //[start] 添加招聘方案

    @RequestMapping("/add")
    public String Add(Model model,HttpServletRequest request,HttpServletResponse response) {
        try {
            String proid=request.getParameter("id");
            ProjectInfo projectInfo=null;
            if (StringTools.trimNotEmpty(proid)){
              projectInfo=  projectService.getpProjectById(proid);
            }
            if (projectInfo!=null){
                model.addAttribute("proid",projectInfo.getId());
                model.addAttribute("proname",projectInfo.getPname());
                model.addAttribute("recruittype",projectInfo.getRecruittype());
                model.addAttribute("pdisplay",projectInfo.getPdisplay());
                model.addAttribute("pseason",projectInfo.getSeason());
                model.addAttribute("state",projectInfo.getState());
            }else{
                model.addAttribute("proname","");
                model.addAttribute("recruittype","");
            }
          /*  List<BaseData> baseDatas = utilService.getBaseData("M", "0");
            StringBuilder strs = new StringBuilder();
            for (BaseData baseData : baseDatas) {
                strs.append("<span rel='" + baseData.getCode() + "'>" + baseData.getName() + "</span>");
            }
            model.addAttribute("areas", strs);*/
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/add";
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    @RequestMapping(value = "/AddAction", method = RequestMethod.POST)
    public void AddAction(HttpServletRequest request, HttpServletResponse response,ProjectInfo project,String flowsJson,String jobsJson) {
        try {
            BaseUser usr = utilService.getSessionUser(request);
            //招聘方案信息
            if(project!=null&&StringTools.trimNotEmpty(project.getState())&&project.getState()!=EnumTools.ProjectState.编辑中.ordinal()){
                utilService.printJsonResult(false, "该方案已发布不能进行编辑！", "no", response);
            }else{
                Boolean result = SaveOrUpdateProject(project, flowsJson, jobsJson, usr);
                if (result) {
                    utilService.printJsonResult(true, "操作成功！", "no", response);
                } else {
                    utilService.printJsonResult(false, "操作失败！", "no", response);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }


    @SuppressWarnings({"rawtypes", "unchecked"})
    @Deprecated
    public void AddAction_bak(HttpServletRequest request, HttpServletResponse response,ProjectInfo project,String flowsJson,String jobsJson) {
        try {
            List addlList = new ArrayList();
            BaseUser usr = utilService.getSessionUser(request);
            JSONArray flowsArray = JSONArray.fromObject(flowsJson.toLowerCase());
            //System.out.println("JSONArray:"+flowsArray);
            List<ProjectInfoFlow> flows = JSONArray.toList(flowsArray, new ProjectInfoFlow(), new JsonConfig());

            JSONArray jobsArray = JSONArray.fromObject(jobsJson.toLowerCase());
            //System.out.println("JSONArray:"+jobsArray);
            List<ProjectInfoJobs> jobs = JSONArray.toList(jobsArray, new ProjectInfoJobs(), new JsonConfig());
            //招聘方案信息
            String id = null;
            if (project!=null&&StringTools.trimNotEmpty(project.getId())){
              ProjectInfo _projectInfo = projectService.getpProjectById(project.getId());

            }else {
                //ProjectInfo project = form.getProject();
                //不同招聘类型在招聘方案中用不同的前缀区分
                /*if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {
                    id = "A_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()) {
                    id = "B_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                    id = "C_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                    id = "D_" + UUID.randomUUID().toString();
                }*/

                if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {
                    id = "A_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()) {
                    if ("春季".equals(project.getSeason())) {
                        id = "F_" + UUID.randomUUID().toString();
                    } else {
                        id = "B_" + UUID.randomUUID().toString();
                    }
                } else if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                    if ("春季".equals(project.getSeason())) {
                        id = "E_" + UUID.randomUUID().toString();
                    } else {
                        id = "C_" + UUID.randomUUID().toString();
                    }
                } /*else if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                    id = "D_" + UUID.randomUUID().toString();
                }*/

                project.setId(id);
                project.setState(EnumTools.ProjectState.编辑中.ordinal());
                project.setPlanid("-");
                project.setPlanname("-");
                project.setAdduid(usr.getId());
                project.setAdduname(usr.getUname());
                project.setAdddate(new Date());
                addlList.add(project);
            }

          /* 20180807 校园招聘取消招聘地区,用户自己根据方案名称进行区分
           //招聘地区
            if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()) {
                List<ProjectInfoRegion> regions = form.getRegion();
                for (ProjectInfoRegion region : regions) {
                    region.setId(UUID.randomUUID().toString());
                    region.setPid(id);
                    addlList.add(region);
                }
            }*/

            //招聘流程
            //保存用户配置流程
            int order = 1;
            for (ProjectInfoFlow _flow : flows) {
                ProjectInfoFlow flow = new ProjectInfoFlow();
                flow.setId(UUID.randomUUID().toString());
                flow.setFid(_flow.getFid());
                flow.setNickname(_flow.getNickname());
                flow.setPid(id);
                flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                flow.setForder(order);
                flow.setDeptcode(usr.getUdept());
                flow.setDeptname(usr.getUdeptname());
                flow.setDisplay(_flow.getDisplay());
                flow.setStarttime(_flow.getStarttime());
                flow.setEndtime(_flow.getEndtime());
                flow.setRemark(_flow.getRemark());
                addlList.add(flow);
                order++;
            }

            //20190111改为直接根据用户配置流程
            /*if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()||project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
               *//* for (EnumTools.GXFlowState r : EnumTools.GXFlowState.values()) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(r.ordinal());
                    flow.setNickname(r.toString());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(r.ordinal() + 1);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());

                    addlList.add(flow);
                }*//*
               //改为通过页面传入流程
                int order = 1;
                for (ProjectInfoFlow _flow : flows) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(_flow.getFid());
                    flow.setNickname(_flow.getNickname());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(order);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());
                    flow.setDisplay(_flow.getDisplay());
                    flow.setStarttime(_flow.getStarttime());
                    flow.setEndtime(_flow.getEndtime());
                    flow.setRemark(_flow.getRemark());
                    addlList.add(flow);
                    order++;
                }
            *//*} else if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                for (EnumTools.ZZFlowState r : EnumTools.ZZFlowState.values()) {
                    if (r.name().equals("毕业生推荐") || r.name().equals("初审") || r.name().equals("投简历") || r.name().equals("录用")) {
                        ProjectInfoFlow flow = new ProjectInfoFlow();
                        flow.setId(UUID.randomUUID().toString());
                        flow.setFid(r.ordinal());
                        flow.setNickname(r.toString());
                        flow.setPid(id);
                        flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                        flow.setForder(r.ordinal() + 1);
                        flow.setDeptcode(usr.getUdept());
                        flow.setDeptname(usr.getUdeptname());
                        addlList.add(flow);

                    }
                }*//*
            } else if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                int order = 1;
                for (ProjectInfoFlow _flow : flows) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(_flow.getFid());
                    flow.setNickname(_flow.getNickname());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(order);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());
                    flow.setDisplay(_flow.getDisplay());
                    flow.setStarttime(_flow.getStarttime());
                    flow.setEndtime(_flow.getEndtime());
                    flow.setRemark(_flow.getRemark());
                    addlList.add(flow);
                    order++;
                }
            } else if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {
                int order = 1;
                for (ProjectInfoFlow _flow : flows) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(_flow.getFid());
                    flow.setNickname(_flow.getNickname());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(order);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());
                    flow.setDisplay(_flow.getDisplay());
                    flow.setStarttime(_flow.getStarttime());
                    flow.setEndtime(_flow.getEndtime());
                    flow.setRemark(_flow.getRemark());
                    addlList.add(flow);
                    order++;
                }
            }*/



          //  String jobs=request.getParameter("jobsList");
            if(jobs!=null&&jobs.size()>0){
                JSONArray jsonArray= JSONArray.fromObject(jobs);
                List<ProjectInfoJobs> jobsList=(List<ProjectInfoJobs>)JSONArray.toList(jsonArray,new ProjectInfoJobs(),new JsonConfig());
                if (jobsList!=null&&jobsList.size()>0){
                    for (ProjectInfoJobs projectInfoJob : jobsList) {
                        //判断岗位中方案Id是否为空,为空表示是新岗位并为岗位赋值ID和方案ID
                        if (projectInfoJob.getId()==null||projectInfoJob.getId().equalsIgnoreCase("")){
                            projectInfoJob.setPid(id);
                            projectInfoJob.setId(UUID.randomUUID().toString());
                            if (projectInfoJob.getIstemplate()!=null&&projectInfoJob.getIstemplate().trim().equalsIgnoreCase("是")){

                               ProjectInfoJobtemplate projectInfoJobtemplate= createJobTemplate(projectInfoJob.getPid().substring(0,1).toUpperCase(),projectInfoJob,usr);
                               if (projectInfoJobtemplate!=null){
                                   addlList.add(projectInfoJobtemplate);
                               }
                            }
                        }
                    }
                    addlList.addAll(jobsList);
                }
            }
            utilService.addList(addlList);
            utilService.printJsonResult(true, "操作成功！", "no", response);
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }


    public Boolean SaveOrUpdateProject(ProjectInfo project,String flowsJson,String jobsJson,BaseUser usr){
        List addlList = new ArrayList();
        List editList=new ArrayList();
        List delList=new ArrayList();
        Boolean isnew=true;
        try {
            if(project!=null&&StringTools.trimNotEmpty(project.getId())){
                project.setState(EnumTools.ProjectState.编辑中.ordinal());
                project.setPlanid("-");
                project.setPlanname("-");
                project.setAdduid(usr.getId());
                project.setAdduname(usr.getUname());
                project.setAdddate(new Date());
                editList.add(project);
                isnew=false;
            }else{
                String id =null;
                if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {
                    id = "A_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()) {
                    if ("春季".equals(project.getSeason())) {
                     //   id = "F_" + UUID.randomUUID().toString();
                        id = "B_" + UUID.randomUUID().toString();
                        project.setSeason("春季");
                    } else {
                        project.setSeason("秋季");
                        id = "B_" + UUID.randomUUID().toString();
                    }
                } else if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                    if ("春季".equals(project.getSeason())) {
                        id = "E_" + UUID.randomUUID().toString();
                        project.setSeason("春季");
                    } else {
                        id = "C_" + UUID.randomUUID().toString();
                        project.setSeason("秋季");
                    }
                } else if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                    id = "D_" + UUID.randomUUID().toString();
                } else if (project.getRecruittype() == EnumTools.RecruitType.驾驶员招聘.ordinal()) {
                    id = "G_" + UUID.randomUUID().toString();
                }
                project.setId(id);
                project.setState(EnumTools.ProjectState.编辑中.ordinal());
                project.setPlanid("-");
                project.setPlanname("-");
                project.setAdduid(usr.getId());
                project.setAdduname(usr.getUname());
                project.setAdddate(new Date());
                addlList.add(project);
            }
            //招聘流程
            //保存用户配置流程
            JSONArray flowsArray = JSONArray.fromObject(flowsJson);
            if(flowsArray.size()>0){
                for (int i=0;i<flowsArray.size();i++) {
                        JSONObject jsonObject=flowsArray.getJSONObject(i);
                        String table_index=jsonObject.getString("LAY_TABLE_INDEX");
                        ProjectInfoFlow flow= (ProjectInfoFlow) JSONObject.toBean(jsonObject,ProjectInfoFlow.class);
                        flow.setId(UUID.randomUUID().toString());
                        flow.setPid(project.getId());
                        flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                        flow.setForder(Integer.parseInt(table_index));
                        flow.setDeptcode(usr.getUdept());
                        flow.setDeptname(usr.getUdeptname());
                        addlList.add(flow);
                }
            }
            List<BaseData>  baseDatas = utilService.getBaseData("F", "0");
            if(jobsJson!=null&&StringTools.trimNotEmpty(jobsJson)){
                JSONArray jobsArray= JSONArray.fromObject(jobsJson);
                if(flowsArray.size()>0){
                    for (int i=0;i<jobsArray.size();i++) {
                        JSONObject jsonObject=jobsArray.getJSONObject(i);
                        String table_index=jsonObject.getString("LAY_TABLE_INDEX");

                          Object projectJobsB=  JSONObject.toBean(jsonObject);
                        ProjectInfoJobs projectInfoJob= null;
                          try {
                              projectInfoJob=    (ProjectInfoJobs) JSONObject.toBean(jsonObject,ProjectInfoJobs.class);
                          }catch (Exception e){
                            ProjectInfoJobtemplate jobtemplate=  (ProjectInfoJobtemplate) JSONObject.toBean(jsonObject,ProjectInfoJobtemplate.class);
                            projectInfoJob=new ProjectInfoJobs();
                              projectInfoJob.setIstemplate("否");
                              projectInfoJob.setJobdepart(jobtemplate.getJobdepart());
                              projectInfoJob.setEducode(jobtemplate.getEducode());
                              projectInfoJob.setEduname(jobtemplate.getEduname());
                              projectInfoJob.setAgef(jobtemplate.getAgef());
                              projectInfoJob.setAget(jobtemplate.getAget());
                              projectInfoJob.setGender(jobtemplate.getGender());
                              projectInfoJob.setPolitical(jobtemplate.getPolitical());
                              projectInfoJob.setHeight(jobtemplate.getHeight());
                              projectInfoJob.setJobname(jobtemplate.getJobname());
                              projectInfoJob.setMajor(jobtemplate.getMajor());
                              projectInfoJob.setWorkcont(jobtemplate.getWorkcont());
                              projectInfoJob.setWorkreq(jobtemplate.getWorkreq());
                              projectInfoJob.setWorkyear(jobtemplate.getWorkyear());
                              projectInfoJob.setZpcount(jobtemplate.getZpcount());
                              projectInfoJob.setDisplay(jobtemplate.getDisplay());
                              projectInfoJob.setJobtype(jobtemplate.getJobtype());
                         //     projectInfoJob.setJobcode(jobtemplate.());
                          }
                            if (projectInfoJob.getEduname() != null && StringTools.trimNotEmpty(projectInfoJob.getEduname())) {
                                if (baseDatas != null && baseDatas.size() > 0) {
                                    for (BaseData baseData : baseDatas) {
                                        if (baseData.getName().equalsIgnoreCase(projectInfoJob.getEduname())) {
                                            projectInfoJob.setEducode(baseData.getCode());
                                            break;
                                        }
                                    }
                                }

                            }
                        projectInfoJob.setId(UUID.randomUUID().toString());
                        projectInfoJob.setPid(project.getId());
                        if (projectInfoJob.getIstemplate()!=null&&projectInfoJob.getIstemplate().trim().equalsIgnoreCase("是")){
                            ProjectInfoJobtemplate projectInfoJobtemplate= null;
                            try {
                                projectInfoJobtemplate = createJobTemplate(projectInfoJob.getPid().substring(0,1).toUpperCase(),projectInfoJob,usr);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (projectInfoJobtemplate!=null){
                                addlList.add(projectInfoJobtemplate);
                            }
                        }else{
                            projectInfoJob.setIstemplate("否");
                        }
                        addlList.add(projectInfoJob);
                    }
                }
            }
            if(!isnew){
                delList.addAll(projectService.getflowbypid(project.getId()));
                delList.addAll(projectService.getjobsbypid(project.getId()));
                if(delList.size()>0){
                    utilService.delList(delList);
                }
            }
            if(editList.size()>0){
                utilService.editList(editList);
            }
            if(addlList.size()>0){
                utilService.addList(addlList);
            }
           return true;
        } catch (Exception e) {
            e.printStackTrace();
           return false;
        }

    }


    //[end]

    //[start] 修改招聘方案

    @RequestMapping("/edit")
    public String Edit(HttpServletRequest request, Model model) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);
            model.addAttribute("project", project);
            StringBuilder fstr = new StringBuilder();
            List<ProjectInfoFlow> flows = projectService.getflowbypid(id);
            if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()||project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                List<ProjectInfoRegion> regions = projectService.getRegionbypid(id);

                List<BaseData> baseDatas = utilService.getBaseData("M", "0");
                StringBuilder strs = new StringBuilder();
                StringBuilder vals = new StringBuilder();

                int xi = 0;
                for (BaseData baseData : baseDatas) {
                    boolean ck = false;
                    for (ProjectInfoRegion region : regions) {
                        if (region.getRcode().equals(baseData.getCode())) {
                            ck = true;
                        }
                    }

                    if (ck) {
                        strs.append("<span rel='" + baseData.getCode() + "' class='checked'>" + baseData.getName() + "</span>");
                        vals.append("<input type='hidden' name='region[" + xi + "].rcode' value='" + baseData.getCode() + "' />");
                        vals.append("<input type='hidden' name='region[" + xi + "].region' value='" + baseData.getName() + "' />");
                        xi++;
                    } else {
                        strs.append("<span rel='" + baseData.getCode() + "'>" + baseData.getName() + "</span>");
                    }
                }
                model.addAttribute("areas", strs.append(vals));
                int num1 = 0;
               /* for (ProjectInfoFlow flow : flows) {
                    fstr.append("<tr><td>" + (num1 + 1) + "</td>");
                    if (flow.getFid() < 2 || flow.getFid() > 3) {
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].fid' value='" + flow.getFid() + "' /></td>");
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></td>");
                        fstr.append("<td></td></tr>");
                    } else {
                        fstr.append("<td><div><input type='hidden' value='" + flow.getFid() + "'/><select name='flow[" + num1 + "].fid'><option value='2'>面试</option><option value='3'>笔试</option></select></div></td>");
                        fstr.append("<td><div><input type='text' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></div></td>");
                        fstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");
                    }

                    num1++;
                }*/

                for (ProjectInfoFlow flow : flows) {
                    fstr.append("<tr><td>" + (num1 + 1) + "</td>");
                    if (flow.getFid() < 1 || flow.getFid() > 6) {
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].fid' value='" + flow.getFid() + "' /></td>");
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></td>");
                        fstr.append("<td></td></tr>");
                    } else {
                        fstr.append("<td><div><input type='hidden' value='" + flow.getFid() + "'/><select name='flow[" + num1 + "].fid'><option value='1'>笔试</option><option value='2'>资料审核</option><option value='3'>面试</option><option value='4'>实作</option><option value='5'>体检</option><option value='6'>背景调查</option><option value='6'>背景调查</option></select></div></td>");
                        fstr.append("<td><div><input type='text' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></div></td>");
                        fstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");
                    }

                    num1++;
                }
            }

            /*if(project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                int num1 = 0;
                for (ProjectInfoFlow flow : flows) {
                    fstr.append("<tr><td>" + (num1 + 1) + "</td>");
                    if (flow.getFid() < 2 || flow.getFid() > 3) {
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].fid' value='" + flow.getFid() + "' /></td>");
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></td>");
                        fstr.append("<td></td></tr>");
                    } else {
                        fstr.append("<td><div><input type='hidden' value='" + flow.getFid() + "'/><select name='flow[" + num1 + "].fid'><option value='2'>面试</option><option value='3'>笔试</option></select></div></td>");
                        fstr.append("<td><div><input type='text' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></div></td>");
                        fstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");
                    }

                    num1++;

                }
            }*/

            /*if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                int num1 = 0;
                for (ProjectInfoFlow flow : flows) {
                    fstr.append("<tr><td>" + (num1 + 1) + "</td>");
                    if (flow.getFid() < 2 || flow.getFid() > 3) {
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].fid' value='" + flow.getFid() + "' /></td>");
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></td>");
                        fstr.append("<td></td></tr>");
                    } else {
                        fstr.append("<td><div><input type='hidden' value='" + flow.getFid() + "'/><select name='flow[" + num1 + "].fid'><option value='2'>面试</option><option value='3'>笔试</option></select></div></td>");
                        fstr.append("<td><div><input type='text' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></div></td>");
                        fstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");
                    }

                    num1++;
                }
                //改为动态通用流程
                //model.addAttribute("nzflows", fstr);
            }*/

            if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {

                int num1 = 0;
                for (ProjectInfoFlow flow : flows) {
                    fstr.append("<tr><td>" + (num1 + 1) + "</td>");
                    if (flow.getFid() < 1 || flow.getFid() > 6) {
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].fid' value='" + flow.getFid() + "' /></td>");
                        fstr.append("<td>" + flow.getNickname() + "<input type='hidden' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></td>");
                        fstr.append("<td></td></tr>");
                    } else {
                        fstr.append("<td><div><input type='hidden' value='" + flow.getFid() + "'/><select name='flow[" + num1 + "].fid'><option value='1'>笔试</option><option value='2'>资料审核</option><option value='3'>面试</option><option value='4'>实作</option><option value='5'>体检</option><option value='6'>背景调查</option></select></div></td>");
                        fstr.append("<td><div><input type='text' name='flow[" + num1 + "].nickname' value='" + flow.getNickname() + "' /></div></td>");
                        fstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");
                    }

                    num1++;
                }
                //改为动态通用流程
        //                model.addAttribute("szflows", fstr);
            }
            model.addAttribute("flows", fstr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/edit";
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    @RequestMapping(value = "/EditAction", method = RequestMethod.POST)
    public void EditAction(HttpServletRequest request, HttpServletResponse response, ProjectForm form) {
        try {
            BaseUser usr = utilService.getSessionUser(request);

            //招聘方案信息
            String id = form.getProject().getId();
            ProjectInfo project = projectService.getpProjectById(id);
            if (project.getState() != EnumTools.ProjectState.编辑中.ordinal()) {
                utilService.printJsonResult(false, "当前状态下的招聘方案不能修改", "no", response);
                return;
            }

            project.setPname(form.getProject().getPname());

            List addList = new ArrayList();
            List delList = new ArrayList();

            //招聘地区
            /*if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()) {
                List<ProjectInfoRegion> regions = form.getRegion();
                for (ProjectInfoRegion region : regions) {
                    region.setId(UUID.randomUUID().toString());
                    region.setPid(id);
                    addList.add(region);
                }
            }*/

            //招聘流程
            if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()||project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                /*for (EnumTools.GXFlowState r : EnumTools.GXFlowState.values()) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(r.ordinal());
                    flow.setNickname(r.toString());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(r.ordinal() + 1);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());

                    addList.add(flow);
                }*/
                int order = 1;
                for (ProjectInfoFlow _flow : form.getFlows()) {
                    if(_flow!=null&&_flow.getFid()!=null) {
                        ProjectInfoFlow flow = new ProjectInfoFlow();
                        flow.setId(UUID.randomUUID().toString());
                        flow.setFid(_flow.getFid());
                        flow.setNickname(_flow.getNickname());
                        flow.setPid(id);
                        flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                        flow.setForder(order);
                        flow.setDeptcode(usr.getUdept());
                        flow.setDeptname(usr.getUdeptname());
                        addList.add(flow);
                        order++;
                    }
                }
            /*} else if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                for (EnumTools.ZZFlowState r : EnumTools.ZZFlowState.values()) {
                    if (r.name().equals("毕业生推荐") || r.name().equals("初审") || r.name().equals("投简历") || r.name().equals("录用")) {
                        ProjectInfoFlow flow = new ProjectInfoFlow();
                        flow.setId(UUID.randomUUID().toString());
                        flow.setFid(r.ordinal());
                        flow.setNickname(r.toString());
                        flow.setPid(id);
                        flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                        flow.setForder(r.ordinal() + 1);
                        flow.setDeptcode(usr.getUdept());
                        flow.setDeptname(usr.getUdeptname());

                        addList.add(flow);
                    }
                }*/
            } /*else if (project.getRecruittype() == EnumTools.RecruitType.内部招聘.ordinal()) {
                int order = 1;
                for (ProjectInfoFlow _flow : form.getFlows()) {
                    ProjectInfoFlow flow = new ProjectInfoFlow();
                    flow.setId(UUID.randomUUID().toString());
                    flow.setFid(_flow.getFid());
                    flow.setNickname(_flow.getNickname());
                    flow.setPid(id);
                    flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                    flow.setForder(order);
                    flow.setDeptcode(usr.getUdept());
                    flow.setDeptname(usr.getUdeptname());

                    addList.add(flow);
                    order++;
                }
            } */else if (project.getRecruittype() == EnumTools.RecruitType.社会招聘.ordinal()) {
                int order = 1;
                for (ProjectInfoFlow _flow : form.getFlows()) {
                    if(_flow!=null&&_flow.getFid()!=null) {
                        ProjectInfoFlow flow = new ProjectInfoFlow();
                        flow.setId(UUID.randomUUID().toString());
                        flow.setFid(_flow.getFid());
                        flow.setNickname(_flow.getNickname());
                        flow.setPid(id);
                        flow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                        flow.setForder(order);
                        flow.setDeptcode(usr.getUdept());
                        flow.setDeptname(usr.getUdeptname());

                        addList.add(flow);
                        order++;
                    }
                }
            }
            delList.addAll(projectService.getflowbypid(id));
            delList.addAll(projectService.getRegionbypid(id));

            utilService.editList(project, delList, addList);
            utilService.printJsonResult(true, "操作成功！", "no", response);
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

    //[end]
    //关闭招聘方案
    @SuppressWarnings({"rawtypes", "unchecked"})
    @RequestMapping(value = "/CloseActions", method = RequestMethod.POST)
    public void CloseActions(HttpServletRequest request, HttpServletResponse response) {
        try {
         //   String id = request.getParameter("id").trim();
         //   ProjectInfo project = projectService.getpProjectById(id);

            List colseList = new ArrayList();
            String[] ids = request.getParameterValues("id");
            for (String id : ids) {
                ProjectInfo projectInfo = projectService.getpProjectById(id);
                projectInfo.setState(EnumTools.ProjectState.已关闭.ordinal());
                utilService.editObject(projectInfo);
            }
            utilService.printJsonResult(true, "操作成功！", "no", response);
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

    //[start] 删除招聘方案

    @SuppressWarnings({"rawtypes", "unchecked"})
    @RequestMapping(value = "/DelAction", method = RequestMethod.POST)
    public void DelAction(HttpServletRequest request, HttpServletResponse response) {
        try {
            List delList = new ArrayList();
            String[] ids = request.getParameterValues("id");
            int numALL=0;
            int numCnt=0;
            for (String id : ids) {
                numALL++;
                ProjectInfo project = projectService.getpProjectById(id);
                if (project.getState() == EnumTools.ProjectState.编辑中.ordinal()) {
                    delList.add(project);
                    delList.addAll(projectService.getflowbypid(id));
                    delList.addAll(projectService.getjobsbypid(id));
                    delList.addAll(projectService.getRegionbypid(id));
                    numCnt++;
                }
            }

            utilService.delList(delList);
            if(numALL == numCnt){
                utilService.printJsonResult(true, "删除成功！", "no", response);
            }else {
                if(numCnt>0)
                    utilService.printJsonResult(true, "只删除了“编辑中”的招聘方案，其他未处理！", "no", response);
                else
                    utilService.printJsonResult(false, "只能选择删除“编辑中”的招聘方案！", "no", response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "删除失败！", "no", response);
        }
    }

    //[end]
    @ResponseBody
    @RequestMapping(value = "/getPubJson", method = RequestMethod.POST)
    public LayuiDataTableResultBean getPubJson(HttpServletRequest request) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);

            JSONObject jsonObject = new JSONObject();

            jsonObject.put("zpPlanName", project.getPlanname());
            jsonObject.put("zpPName", project.getPname());
            jsonObject.put("zpRecruittype", EnumTools.RecruitType.values()[project.getRecruittype()]);

            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCode(0);
            result.setMsg("success");
            result.setCount(1);
            result.setData(jsonObject);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCount(-1);
            result.setMsg("err");
            return result;
        }
    }

    /**
     * 批量添加实施流程
     * @param request
     * @param model
     * @return
     */
/*    @RequestMapping("/flowTransfer")
    public String flowTransfer(HttpServletRequest request, Model model) {
        try {
            String recruittypeVal = request.getParameter("recruittype").trim();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/flowTransfer";
    }*/


    //[start] 发布招聘方案

    @RequestMapping("/pub")
    public String Pub(HttpServletRequest request, Model model) {
        try {
            String id = request.getParameter("id").trim();
/*            ProjectInfo project = projectService.getpProjectById(id);
            StringBuilder str = new StringBuilder();
            str.append("<b>招聘计划：</b>" + project.getPlanname());
            str.append("<br><b>招聘方案：</b>" + project.getPname());
            str.append("<br><b>招聘方式：</b>" + EnumTools.RecruitType.values()[project.getRecruittype()]);
            str.append("<input type='hidden' name='id' value='" + id + "' />");
            model.addAttribute("project", str);*/
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/pub";
    }



/*    @RequestMapping("/pub")
    public String Pub(HttpServletRequest request, Model model) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);
            StringBuilder str = new StringBuilder();
            str.append("<b>招聘计划：</b>" + project.getPlanname());
            str.append("<br><b>招聘方案：</b>" + project.getPname());
            str.append("<br><b>招聘方式：</b>" + EnumTools.RecruitType.values()[project.getRecruittype()]);
            str.append("<input type='hidden' name='id' value='" + id + "' />");
            model.addAttribute("project", str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/pub";
    }*/

    @ResponseBody
    @RequestMapping(value = "/PubActions", method = RequestMethod.POST)
    public void PubActions(HttpServletRequest request, HttpServletResponse response) {
        try {
            String id = request.getParameter("id").trim();
            Date endDate = DateTools.toLenDate(request.getParameter("enddate").trim() + " 23:59:59");
            Date startDate = DateTools.toLenDate(request.getParameter("startdate").trim() + " 0:0:0");
            ProjectInfo project = projectService.getpProjectById(id);

            if (project.getState() == EnumTools.ProjectState.编辑中.ordinal()) {
                List editlist = new ArrayList();

                //开启第一步流程
                ProjectInfoFlow flow = projectService.getflow(project.getId(), 0);
                flow.setState(EnumTools.PlanFlowState.进行中.ordinal());
                editlist.add(flow);

                project.setStartdate(startDate);
                project.setEnddate(endDate);
                project.setState(EnumTools.ProjectState.已发布.ordinal());
                editlist.add(project);

                utilService.editList(editlist);
                utilService.printJsonResult(true, "操作成功！", "no", response);
            } else {
                utilService.printJsonResult(false, "当前状态下的招聘方案不能执行此操作！", "no", response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

   /* @SuppressWarnings({"unchecked", "rawtypes"})
    @RequestMapping(value = "/PubAction", method = RequestMethod.POST)
    public void PubAction(HttpServletRequest request, HttpServletResponse response) {
        try {
            String id = request.getParameter("id").trim();
            Date endDate = DateTools.toLenDate(request.getParameter("enddate").trim() + " 23:59:59");
            Date startDate = DateTools.toLenDate(request.getParameter("startdate").trim() + " 0:0:0");
            ProjectInfo project = projectService.getpProjectById(id);
            if (project.getState() == EnumTools.ProjectState.编辑中.ordinal()) {
                List editlist = new ArrayList();

                //开启第一步流程
                ProjectInfoFlow flow = projectService.getflow(project.getId(), 0);
                flow.setState(EnumTools.PlanFlowState.进行中.ordinal());
                editlist.add(flow);

                project.setStartdate(startDate);
                project.setEnddate(endDate);
                project.setState(EnumTools.ProjectState.已发布.ordinal());
                editlist.add(project);

                utilService.editList(editlist);
                utilService.printJsonResult(true, "操作成功！", "no", response);
            } else {
                utilService.printJsonResult(false, "当前状态下的招聘方案不能执行此操作！", "no", response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }*/

    /**
     * 查看招聘方案 (基本信息)
     * @param request
     * @return
     */
/*    @ResponseBody
    @RequestMapping(value = "/getProViewLayuiJson", method = RequestMethod.GET)
    public LayuiDataTableResultBean getProViewLayuiJson(HttpServletRequest request) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);

            JSONArray jsonArray = new JSONArray();

            JSONObject jsonObject = JSONObject.fromObject(project);
            //基本信息
            jsonObject.put("'pname'", project.getPname());
            jsonObject.put("recruittype",EnumTools.RecruitType.values()[project.getRecruittype()]);
            jsonObject.put("state",EnumTools.ProjectState.values()[project.getState()]);
            jsonObject.put("startdate",(project.getStartdate() == null ? "" : DateTools.toLenStr(project.getStartdate())));
            jsonObject.put("enddate",(project.getEnddate() == null ? "" : DateTools.toLenStr(project.getEnddate())));

            //实施流程
            String hrcode = utilService.getConfig("hrcode");//招聘主管部门编码
            List<ProjectInfoFlow> flows = projectService.getThisFlowDept(id, hrcode);
            String  strs ="";
            int i = 1;
            for (ProjectInfoFlow flow : flows) {
                if (i == flows.size()) {
                    strs = strs+flow.getNickname() ;
                }else {
                    strs = strs + flow.getNickname() + " > ";
                }
                i++;
            }
            jsonObject.put("flowdept",strs);
            jsonArray.add(jsonObject);

            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCode(0);
            result.setMsg("success");
            result.setCount(1);
            result.setData(jsonArray);

            return result;
        } catch (Exception e) {
            e.printStackTrace();
            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCount(-1);
            result.setMsg("err");
            return result;
        }
      //  return "/Project/view";
    }*/

    /**
     * 查看招聘方案 (岗位信息)
     * @param request
     * @return
     */

    @ResponseBody
    @RequestMapping(value = "/getProViewContentLayuiJson", method = RequestMethod.GET)
    public LayuiDataTableResultBean getProViewContentLayuiJson(HttpServletRequest request) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);

            JSONArray jsonArray = new JSONArray();
            JSONObject jsonObject = new JSONObject();

            //招聘岗位
            List<ProjectInfoJobs> jobs = projectService.getjobsbypid(id);
           // StringBuilder dstr = new StringBuilder();
            int num = 0;
            for (ProjectInfoJobs job : jobs) {
                jsonObject.put("id",num + 1);
                jsonObject.put("jobname",job.getJobname());
                jsonObject.put("zpcount",job.getZpcount());
                if((job.getAgef() == null)||(job.getAget() == null))
                    jsonObject.put("age","");
                else
                    jsonObject.put("age",(job.getJobname()+"-"+job.getAget()));
                if(job.getWorkyear() == null)
                    jsonObject.put("workyear","");
                else
                    jsonObject.put("workyear",job.getWorkyear() + "年以上");
                jsonObject.put("eduname",job.getEduname());
                jsonObject.put("gender",job.getGender());
                num++;
                jsonArray.add(jsonObject);
            }

            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCode(0);
            result.setMsg("success");
            result.setCount(num);
            result.setData(jsonArray);

            return result;
        } catch (Exception e) {
            e.printStackTrace();
            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCount(-1);
            result.setMsg("err");
            return result;
        }
        //  return "/Project/view";
    }

    @ResponseBody
    @RequestMapping(value = "/getProViewPicJson", method = RequestMethod.POST)
    public LayuiDataTableResultBean getProViewPicJson(HttpServletRequest request) {
        try {
                String id = request.getParameter("id").trim();
                ProjectInfo project = projectService.getpProjectById(id);

                JSONArray jsonArray = new JSONArray();
                JSONObject jsonObject = new JSONObject();

                String hrcode = utilService.getConfig("hrcode");//招聘主管部门编码
                List<ProjectInfoFlow> flows = projectService.getThisFlowDept(id, hrcode);

                //各阶段通过人数情况
              //  StringBuilder cstr = new StringBuilder();
                if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()||project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                    jsonObject.put("flags", true);
                    jsonObject.put("title", project.getPname() + "各阶段人数分布");
                    jsonObject.put("xAxis_categories", "['投简历','背景调查','体检','岗位分配','录用']");
                    jsonObject.put("yAxis_min", 0);
                    jsonObject.put("yAxis_title", "各阶段应聘者人数 (人)");
                    jsonObject.put("tooltip_headerFormat", "'<span style=\"font-size:10px\">{point.key}</span><table>'");
                    jsonObject.put("tooltip_pointFormat", "'<tr><td style=\"color:{series.color};padding:0\">{series.name}: </td><td style=\"padding:0\"><b>{point.y:f} 人</b></td></tr>'");
                    jsonObject.put("tooltip_footerFormat", "'</table>'");
                    jsonObject.put("shared", false);
                    jsonObject.put("useHTML", true);
                    jsonObject.put("plotOptions_column_pointPadding", 0.2);
                    jsonObject.put("plotOptions_column_borderWidth",  0);
                    int c1 = projectService.getGXFlowUserCount(project.getId(), "pid", project.getId());
                    int c2 = projectService.getGXFlowUserCount(project.getId(), "rstate", "已投简历");
                    int c3 = projectService.getGXFlowUserCount(project.getId(), "zsstate", "背景调查通过");
                    int c4 = projectService.getGXFlowUserCount(project.getId(), "tjstate", "体检通过");
                    int c5 = projectService.getGXFlowUserCount(project.getId(), "gwstate", "已分配");
                    int c6 = projectService.getGXFlowUserCount(project.getId(), "bdstate", "已报到");
                    jsonObject.put("series_name1", "本阶段总人数");
                    jsonObject.put("series_data1", "[" + c1 + ", " + c2 + ", " + c3 + ", " + c4 + ", " + c5 + "]");
                    jsonObject.put("series_name2", "本阶段通过人数");
                    jsonObject.put("series_data2", "[" + c2 + ", " + c3 + ", " + c4 + ", " + c5 + ", " + c6 + "]");
                }else {
                    jsonObject.put("flags", false);
                }

                LayuiDataTableResultBean result = new LayuiDataTableResultBean();
                result.setCode(0);
                result.setMsg("success");
                result.setCount(1);
                result.setData(jsonObject);

            return result;
        } catch (Exception e) {
            e.printStackTrace();
            LayuiDataTableResultBean result = new LayuiDataTableResultBean();
            result.setCount(-1);
            result.setMsg("err");
            return result;
        }
    }


    //[start] 查看招聘方案
    @RequestMapping("/view")
    public String View(HttpServletRequest request, Model model){
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);
            //基本信息
            StringBuilder str = new StringBuilder();
            str.append("<tr><td width='80'>招聘方案：</td><td colspan=3>" + project.getPname() + "</td></tr>");
            str.append("<tr><td width='80'>招聘方式：</td><td>" + EnumTools.RecruitType.values()[project.getRecruittype()] + "</td>");
            str.append("<td width='80'>当前状态：</td><td>" + EnumTools.ProjectState.values()[project.getState()] + "</td></tr>");

            //实施流程
            String hrcode = utilService.getConfig("hrcode");//招聘主管部门编码
            List<ProjectInfoFlow> flows = projectService.getThisFlowDept(id, hrcode);
            str.append("<tr><td>实施流程：</td><td colspan='3'>");
            int i = 1;
            for (ProjectInfoFlow flow : flows) {
                if (i == flows.size()) {
                    str.append(flow.getNickname() + "</td></tr>");
                }else {
                    str.append(flow.getNickname() + "&emsp;>&emsp;");
                }
                i++;
            }
            model.addAttribute("project", str);
            model.addAttribute("pname", project.getPname());

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/view";
    }


 /*   @RequestMapping("/view")
    public String View(HttpServletRequest request, Model model) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfo project = projectService.getpProjectById(id);
            //基本信息
            StringBuilder str = new StringBuilder();
            str.append("<tr><td width='80'>招聘方案：</td><td colspan=3>" + project.getPname() + "</td></tr>");
            str.append("<tr><td width='80'>招聘方式：</td><td>" + EnumTools.RecruitType.values()[project.getRecruittype()] + "</td>");
            str.append("<td width='80'>当前状态：</td><td>" + EnumTools.ProjectState.values()[project.getState()] + "</td></tr>");

            //实施流程
            String hrcode = utilService.getConfig("hrcode");//招聘主管部门编码
            List<ProjectInfoFlow> flows = projectService.getThisFlowDept(id, hrcode);
            str.append("<tr><td>实施流程：</td><td colspan='3'>");
            int i = 1;
            for (ProjectInfoFlow flow : flows) {
                if (i == flows.size()) {
                    str.append(flow.getNickname() + "</td></tr>");
                }else {
                    str.append(flow.getNickname() + "&emsp;>&emsp;");
                }
                i++;
            }
            model.addAttribute("project", str);
            model.addAttribute("pname", project.getPname());


            //招聘岗位
            List<ProjectInfoJobs> jobs = projectService.getjobsbypid(id);
            StringBuilder dstr = new StringBuilder();
            int num = 0;
            for (ProjectInfoJobs job : jobs) {
                dstr.append("<tr><td><span>" + (num + 1) + "</span><input type='hidden' value='" + job.getId() + "'></td>");

                if((job.getAgef() == null)||(job.getAget() == null))
                    dstr.append("<td>" + job.getJobname() + "</td><td>" + job.getZpcount() + "</td><td></td>");
                else
                    dstr.append("<td>" + job.getJobname() + "</td><td>" + job.getZpcount() + "</td><td>" + job.getAgef() + "-" + job.getAget() + "</td>");

                if(job.getWorkyear() == null)
                    dstr.append("<td></td><td>" + job.getEduname() + "</td><td>" + job.getGender() + "</td>");
                else
                    dstr.append("<td>" + job.getWorkyear() + "年以上</td><td>" + job.getEduname() + "</td><td>" + job.getGender() + "</td>");
                *//*dstr.append("<td><button type='button' onfocus='blur()' class='del'></button></td></tr>");*//*
                num++;
            }
            model.addAttribute("jobs", dstr);

            //各阶段通过人数情况
            StringBuilder cstr = new StringBuilder();
           *//*if (project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                cstr.append("$('#container').highcharts({chart: {type: 'column'},title: {text: '" + project.getPname() + "各阶段人数分布'},");
                cstr.append("xAxis: {categories: ['毕业生推荐','初审','投简历','面试','背景调查','体检','岗位分配','录用']},yAxis: {min: 0,title: {");
                cstr.append("text: '各阶段应聘者人数 (人)'}},tooltip: {headerFormat: '<span style=\"font-size:10px\">{point.key}</span><table>',");
                cstr.append("pointFormat: '<tr><td style=\"color:{series.color};padding:0\">{series.name}: </td><td style=\"padding:0\"><b>{point.y:f} 人</b></td></tr>',");
                cstr.append("footerFormat: '</table>',shared: false,useHTML: true},plotOptions: {column: {pointPadding: 0.2,borderWidth: 0}},");
                int c1 = projectService.getZZFlowUserCount(project.getId(), "pid", project.getId());
                int c2 = projectService.getZZFlowUserCount(project.getId(), "state", "1");
                int c3 = projectService.getZZFlowUserCount(project.getId(), "rstate", "已投简历");
                int c4 = projectService.getZZFlowUserCount(project.getId(), "msstate", "面试通过");
                int c5 = projectService.getZZFlowUserCount(project.getId(), "zsstate", "背景调查通过");
                int c6 = projectService.getZZFlowUserCount(project.getId(), "tjstate", "体检通过");
                int c7 = projectService.getZZFlowUserCount(project.getId(), "gwstate", "已分配");
                int c8 = projectService.getZZFlowUserCount(project.getId(), "bdstate", "已报到");
                cstr.append("series: [{name: '本阶段总人数',data: [" + c1 + ", " + c1 + ", " + c2 + ", " + c3 + ", " + c4 + ", " + c5 + ", " + c6 + ", " + c7 + "]},{");
                cstr.append("name: '本阶段通过人数',data: [" + c1 + ", " + c2 + ", " + c3 + ", " + c4 + ", " + c5 + ", " + c6 + ", " + c7 + ", " + c8 + "]}]});");
            } else*//*
                if (project.getRecruittype() == EnumTools.RecruitType.高校校园招聘.ordinal()||project.getRecruittype() == EnumTools.RecruitType.中专校园招聘.ordinal()) {
                cstr.append("$('#container').highcharts({chart: {type: 'column'},title: {text: '" + project.getPname() + "各阶段人数分布'},");
                cstr.append("xAxis: {categories: ['投简历','背景调查','体检','岗位分配','录用']},yAxis: {min: 0,title: {");
                cstr.append("text: '各阶段应聘者人数 (人)'}},tooltip: {headerFormat: '<span style=\"font-size:10px\">{point.key}</span><table>',");
                cstr.append("pointFormat: '<tr><td style=\"color:{series.color};padding:0\">{series.name}: </td><td style=\"padding:0\"><b>{point.y:f} 人</b></td></tr>',");
                cstr.append("footerFormat: '</table>',shared: false,useHTML: true},plotOptions: {column: {pointPadding: 0.2,borderWidth: 0}},");
                int c1 = projectService.getGXFlowUserCount(project.getId(), "pid", project.getId());
                int c2 = projectService.getGXFlowUserCount(project.getId(), "rstate", "已投简历");
                int c3 = projectService.getGXFlowUserCount(project.getId(), "zsstate", "背景调查通过");
                int c4 = projectService.getGXFlowUserCount(project.getId(), "tjstate", "体检通过");
                int c5 = projectService.getGXFlowUserCount(project.getId(), "gwstate", "已分配");
                int c6 = projectService.getGXFlowUserCount(project.getId(), "bdstate", "已报到");
                cstr.append("series: [{name: '本阶段总人数',data: [" + c1 + ", " + c2 + ", " + c3 + ", " + c4 + ", " + c5 + "]},{");
                cstr.append("name: '本阶段通过人数',data: [" + c2 + ", " + c3 + ", " + c4 + ", " + c5 + ", " + c6 + "]}]});");
            }
            model.addAttribute("js", cstr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/view";
    }*/

    //[end]

    //[start] 添加招聘岗位

    @RequestMapping("/AddJob")
    public String AddJob(HttpServletRequest request, Model model) {
        try {
            String pid= request.getParameter("pid").trim();
            model.addAttribute("pid",pid);
            String projectType=request.getParameter("ptype").trim();
            if(projectType.equalsIgnoreCase("1")){
                projectType="B";
            }else if(projectType.equalsIgnoreCase("2")){
                projectType="C";
            }else if(projectType.equalsIgnoreCase("3")){
                projectType="A";
            }else if(projectType.equalsIgnoreCase("4")){
                projectType="D";
            }
            model.addAttribute("ptype",projectType);
            List<ProjectInfoJobtemplate> projectInfoJobtemplateList= projectService.findProjectInfoJobTemplateByLike("启用",null,null,projectType);
            StringBuffer jobtemps=new StringBuffer();
            if(projectInfoJobtemplateList.size()>0){
                for (int i = 0; i <projectInfoJobtemplateList.size() ; i++) {
                    String tempname=projectInfoJobtemplateList.get(i).getTempname();
                    if(tempname!=null&&tempname.length()>0){
                        jobtemps.append("<tr><td id=jobtemp_"+projectInfoJobtemplateList.get(i).getId()+">"+tempname+"</td></tr>");
                    }
                }
            }
            if (jobtemps.length()>0){
                model.addAttribute("jobtemps",jobtemps);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/addjob";
    }


    @RequestMapping("/AddJobByWeb")
    public String AddJobByWeb(HttpServletRequest request, Model model) {
        String projectType=request.getParameter("ptype").trim();
        if(projectType.equalsIgnoreCase("1")){
            projectType="B";
        }else if(projectType.equalsIgnoreCase("2")){
            projectType="C";
        }else if(projectType.equalsIgnoreCase("3")){
            projectType="A";
        }else if(projectType.equalsIgnoreCase("4")){
            projectType="D";
        }
        model.addAttribute("ptype",projectType);
        return "/Project/addJobByWeb";
    }

    @RequestMapping(value = "/AddJobAction", method = RequestMethod.POST)
    public void AddJobAction(HttpServletRequest request, HttpServletResponse response, ProjectInfoJobs job) {
        try {
            String saveType=request.getParameter("tempsavetype");

            List addList=new ArrayList();
           ProjectInfoJobs projectInfoJobs= projectService.getProjectInfoJob(job.getPid(), job.getJobname());
            if (projectInfoJobs != null) {
                utilService.printJsonResult(false, "该方案中已存在添加的岗位！", "no", response);
            } else {
                job.setId(UUID.randomUUID().toString());
                    ProjectInfoJobtemplate jobtemplate=createJobTemplate(saveType,job,utilService.getSessionUser(request));
                    if(jobtemplate!=null) {
                        addList.add(jobtemplate);
                    }

                addList.add(job);
                utilService.addList(addList);
                utilService.printJsonResult(true, "操作成功！", "no", response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

    //[end]

    private ProjectInfoJobtemplate createJobTemplate(String ptype,ProjectInfoJobs job,BaseUser usr) throws Exception {
        ProjectInfoJobtemplate jobtemplate=null;
        //String ptype=request.getParameter("ptype");
        if(ptype!=null) {
            jobtemplate = new ProjectInfoJobtemplate();
            jobtemplate.setId(UUID.randomUUID().toString());
            jobtemplate.setAgef(job.getAgef());
            jobtemplate.setAget(job.getAget());
            jobtemplate.setEducode(job.getEducode());
            jobtemplate.setEduname(job.getEduname());
            jobtemplate.setGender(job.getGender());
            jobtemplate.setJobdepart(job.getJobdepart());
            jobtemplate.setJobname(job.getJobname());
            jobtemplate.setHeight(job.getHeight());
            jobtemplate.setVision(job.getVision());
            jobtemplate.setMajor(job.getMajor());
            jobtemplate.setWorkcont(job.getWorkcont());
            jobtemplate.setWorkreq(job.getWorkreq());
            jobtemplate.setWorkyear(job.getWorkyear());
            jobtemplate.setZpcount(job.getZpcount());
            jobtemplate.setType(ptype);
            jobtemplate.setJobtype(job.getJobtype());
            jobtemplate.setDisplay(job.getDisplay());
            jobtemplate.setState("启用");
            List<ProjectInfoJobtemplate> jobtemplateList = projectService.findProjectInfoJobTemplateByLike("启用", null, job.getJobname(), ptype);
            if (jobtemplateList != null && jobtemplateList.size() > 0) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd");
                jobtemplate.setTempname(job.getJobname() +"["+ dateFormat.format(new Date()) + (jobtemplateList.size() + 1)+"]");
            }else{
                jobtemplate.setTempname(job.getJobname());
            }
            SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            jobtemplate.setCreatetime(dateFormat1.format(new Date()));
           // BaseUser usr = utilService.getSessionUser(request);
            jobtemplate.setCreateuser(usr.getUname());
            return jobtemplate;
        }else{
            return  null;
        }
    }


    //[start] 修改招聘岗位

    @RequestMapping("/EditJob")
    public String EditJob(HttpServletRequest request, Model model) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfoJobs job = projectService.getProjectInfoJob(id);
            model.addAttribute("job", job);
            model.addAttribute("ptype",job.getPid().substring(0,1).toUpperCase());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Project/editjob";
    }

    @RequestMapping("/EditJobByWeb")
    public String EditJobByWeb(HttpServletRequest request, Model model) {
        String projectType=request.getParameter("ptype").trim();
        if(projectType.equalsIgnoreCase("1")){
            projectType="B";
        }else if(projectType.equalsIgnoreCase("2")){
            projectType="C";
        }else if(projectType.equalsIgnoreCase("3")){
            projectType="A";
        }else if(projectType.equalsIgnoreCase("4")){
            projectType="D";
        }
        model.addAttribute("ptype",projectType);
        return "/Project/editJobByWeb";
    }

    @RequestMapping(value = "/EditJobAction", method = RequestMethod.POST)
    public void EditJobAction(HttpServletRequest request, HttpServletResponse response, ProjectInfoJobs job) {
        try {
            if (projectService.getProjectInfoJob(job.getId(), job.getPid(), job.getJobname()) != null) {
                utilService.printJsonResult(false, "该方案中已存在同名岗位！", "no", response);
            } else {
                ProjectInfo projectInfo = projectService.getpProjectById(job.getPid());
                if (projectInfo.getState().equals(EnumTools.ProjectState.编辑中.ordinal())) {
                    utilService.editObject(job);
                    utilService.printJsonResult(true, "操作成功！", "no", response);
                } else {
                    utilService.printJsonResult(false, "当前状态下的招聘方案不能执行此操作！", "no", response);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

    //[end]

    //[start] 查询招聘岗位

    @RequestMapping("/getProJobs")
    public void getProJobs(HttpServletRequest request, HttpServletResponse response) {
        try {
            List<ProjectInfoJobs> jobs = projectService.getjobsbypid(request.getParameter("pid"));
            StringBuilder dstr = new StringBuilder();
            int num = 0;
            for (ProjectInfoJobs job : jobs) {
                dstr.append("<tr><td>" + (num + 1) + "</td>");
                dstr.append("<td>" + job.getJobname() + "</td><td>" + job.getZpcount() + "</td>");
                if (job.getAgef() == null || job.getAgef() == null) {
                    dstr.append("<td>不限</td>");
                } else {
                    dstr.append("<td>" + job.getAgef() + "-" + job.getAget() + "</td>");
                }
                if (job.getWorkyear() == null) {
                    dstr.append("<td>不限</td>");
                } else {
                    dstr.append("<td>" + job.getWorkyear() + "年以上</td>");
                }
                dstr.append("<td>" + job.getEduname() + "</td>");
                if (job.getMajor() == null) {
                    dstr.append("<td>不限</td>");
                } else {
                    dstr.append("<td>" + job.getMajor() + "</td>");
                }
                dstr.append("<td>" + job.getGender() + "</td>");
                dstr.append("<td><button type='button' onfocus='blur()' class='edit'></button>");
                dstr.append("<input type='hidden' value='" + job.getId() + "'>");
                dstr.append("<button type='button' onfocus='blur()' class='del'></button></td></tr>");
                num++;
            }
            utilService.printTextResult(dstr.toString(), response);
        } catch (Exception e) {
            utilService.printTextResult("", response);
        }

    }

    //[end]

    //[start] 删除招聘方案的岗位
    @RequestMapping(value = "/delJobAction", method = RequestMethod.POST)
    public void delJobAction(HttpServletRequest request, HttpServletResponse response) {
        try {
            String id = request.getParameter("id").trim();
            ProjectInfoJobs job = projectService.getProjectInfoJob(id);
            ProjectInfo projectInfo = projectService.getpProjectById(job.getPid());
            if (projectInfo.getState().equals(EnumTools.ProjectState.编辑中.ordinal())) {
                utilService.delObject(job);
                utilService.printJsonResult(true, "操作成功！", "no", response);
            } else {
                utilService.printJsonResult(false, "当前状态下的招聘方案不能执行此操作！", "no", response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printJsonResult(false, "操作失败！", "no", response);
        }
    }

    //[end]


    @ResponseBody
    @RequestMapping(value = "/CloseAction")
    public ResultBean CloseProject(HttpServletRequest request,HttpServletResponse response){
        ResultBean resultBean=new ResultBean();
        try {
            String pid = request.getParameter("pid");
            if (StringTools.notEmpty(pid)){
                ProjectInfo projectInfo = projectService.getpProjectById(pid);
                projectInfo.setState(EnumTools.ProjectState.已关闭.ordinal());
                utilService.editObject(projectInfo);
                resultBean.setState(true);
                resultBean.setMessage("操作成功！");
            }else{
                resultBean.setState(false);
                resultBean.setMessage("请先选择要关闭的招聘方案！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            resultBean.setState(false);
            resultBean.setMessage("操作失败！");
        }

        return  resultBean;

    }

    @ResponseBody
    @RequestMapping(value = "/getProjectFlows")
    public ResultBean getProjectFlows(HttpServletRequest request){
        ResultBean resultBean=new ResultBean();
        String proid=request.getParameter("id");
       BaseUser baseUser= utilService.getSessionUser(request);
        try {
            List<ProjectInfoFlow> flowList;
            flowList=new ArrayList<>();
            if(StringTools.trimNotEmpty(proid)){
               flowList=projectService.getThisFlowDept(proid,baseUser.getUdept());
            }
            /*else{
                flowList=new ArrayList<>();
                ProjectInfoFlow jlsxFlow=new ProjectInfoFlow();
                jlsxFlow.setFid(EnumTools.FlowNomalState.简历筛选.ordinal());
                jlsxFlow.setFname(EnumTools.FlowNomalState.简历筛选.name());
                jlsxFlow.setNickname(EnumTools.FlowNomalState.简历筛选.name());
                jlsxFlow.setState(EnumTools.PlanFlowState.进行中.ordinal());
                jlsxFlow.setDisplay("是");
                ProjectInfoFlow bdFlow=new ProjectInfoFlow();
                bdFlow.setFid(EnumTools.FlowNomalState.录用.ordinal());
                bdFlow.setFname(EnumTools.FlowNomalState.录用.name());
                bdFlow.setNickname(EnumTools.FlowNomalState.录用.name());
                bdFlow.setState(EnumTools.PlanFlowState.未开始.ordinal());
                bdFlow.setDisplay("是");
                flowList.add(jlsxFlow);
                flowList.add(bdFlow);
            }*/
            resultBean.setState(true);
            resultBean.setMessage("操作成功!");
            if (flowList!=null){
                resultBean.setDatas(flowList);
            }else{
                resultBean.setDatas("0");
            }
            if (flowList!=null){
                resultBean.setTotalResult(String.valueOf(flowList.size()));
            }else{
                resultBean.setTotalResult("0");
            }
        } catch (Exception e) {
            e.printStackTrace();
            resultBean.setMessage("操作失败!");
        }
        return  resultBean;
    }

    @ResponseBody
    @RequestMapping(value = "/getProjectJobs")
    public ResultBean getProjectJobs(HttpServletRequest request){
        ResultBean resultBean=new ResultBean();
        String proid=request.getParameter("id");
        BaseUser baseUser= utilService.getSessionUser(request);
        try {
            List<ProjectInfoJobs> jobsList=null;
            if(StringTools.trimNotEmpty(proid)){
                jobsList=projectService.getjobsbypid(proid);
            }
            resultBean.setState(true);
            resultBean.setMessage("操作成功!");
            resultBean.setDatas(jobsList);
            if (jobsList!=null){
                resultBean.setTotalResult(String.valueOf(jobsList.size()));
            }else{
                resultBean.setTotalResult("0");
            }

        } catch (Exception e) {
            e.printStackTrace();
            resultBean.setMessage("操作失败!");
        }
        return  resultBean;
    }

}
